﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NewsAggregatorLibrary;

namespace NewsAggregator
{
    public partial class Related : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string storyID = Request.QueryString["story"];
            if (storyID != null)
            {
                PopulatedStories(storyID);
                hdnStoryID.Value = storyID;
            }
        }

        private void PopulatedStories(string storyID)
        {
            
              StoriesMemberCollection stories = StoriesMember.RetrieveRelated(int.Parse(storyID));

                StoriesMemberCollection returnStories = new StoriesMemberCollection();
                int numberOfObjectsPerPage = 10;
                returnStories.AddRange(stories
                  .Skip(numberOfObjectsPerPage * 0)
                  .Take(numberOfObjectsPerPage));
             
            topStroriesRepeater.DataSource = returnStories;
            topStroriesRepeater.DataBind();         
        }
    }
}